#include "PixelShader.h"

#include "Utils.h"


PixelShader::PixelShader(Graphics& gfx, const std::string& path) : path(path)
{
	Microsoft::WRL::ComPtr<ID3DBlob> pBlob;
	HR(D3DReadFileToBlob(ToWide("CompiledShader/"+path).c_str(), &pBlob));
	HR(GetDevice(gfx)->CreatePixelShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), nullptr, &pPixelShader));
}

void PixelShader::Bind(Graphics& gfx)
{
	(GetContext(gfx)->PSSetShader(pPixelShader.Get(), nullptr, 0u));
}

std::shared_ptr<PixelShader> PixelShader::Create(Graphics& gfx, const std::string& path)
{
	return std::make_shared<PixelShader>(gfx, path);
}

